from rest_framework import serializers
from apps.Basic_data.serializers import BasicSupplierSerializer as VendorSerializer,\
    BasicGoodsSerializer as ProductSerializer
from .models import PurchaseReceipt, \
    PurchaseOrderDetail, PurchaseOrder, PurchaseReceiptDetail, PurchaseReturn, PurchaseReturnDetail


class PurchaseOrderSerializer(serializers.ModelSerializer):
    # vendor = VendorSerializer(read_only=True)

    class Meta:
        model = PurchaseOrder
        fields = '__all__'


class PurchaseOrderDetailSerializer(serializers.ModelSerializer):
    # po = PurchaseOrderSerializer(read_only=True)
    # product = ProductSerializer(read_only=True)

    class Meta:
        model = PurchaseOrderDetail
        fields = '__all__'


class PurchaseReceiptSerializer(serializers.ModelSerializer):
    # vendor = VendorSerializer(read_only=True)
    # purchase_order_detail = PurchaseOrderDetailSerializer(many=True, read_only=True)
    # order_details = PurchaseOrderDetailSerializer(many=True, read_only=True)

    class Meta:
        model = PurchaseReceipt
        fields = '__all__'


class PurchaseReceiptDetailSerializer(serializers.ModelSerializer):
    # purchase_receipt_code = PurchaseReceiptSerializer(read_only=True)
    # purchase_order_detail = PurchaseOrderDetailSerializer(read_only=True)

    class Meta:
        model = PurchaseReceiptDetail
        fields = '__all__'


class PurchaseReturnDetailSerializer(serializers.ModelSerializer):
    # vendor = VendorSerializer(read_only=True)

    class Meta:
        model = PurchaseReturnDetail
        fields = '__all__'


class PurchaseReturnSerializer(serializers.ModelSerializer):
    # purchase_return_code = PurchaseReturnDetailSerializer(many=True, read_only=True)
    # purchase_order_detail = PurchaseOrderDetailSerializer(read_only=True)

    class Meta:
        model = PurchaseReturn
        fields = '__all__'




